const { fstat } = require("fs")
const http = require("http")
const server = http.createServer((req,res)=>{

    const {pathname,searchParams}=new URL(req.url,'http://localhost:8282')
    //得到请求路径
    const publicDir = __dirname +'/public'
    const  filePath = publicDir + pathname
    fs.readFile(filePath,(error,data)=>{
        if(error){
            res.end('<h1>404 not found<h1>')
        }
    })
    if(pathname === '/'){

    }

    res.end('happy birthday to you ')
})
server.listen(8282,()=>{
    console.log('启动服务成功:http://localhost:8282')
})